package kr.hkit.androidcomplete02.ch12;

import kr.hyunist.androidcomplete01.*;
import android.app.*;
import android.os.*;
import android.util.*;
import android.view.*;
import android.widget.*;
import android.widget.AdapterView.OnItemClickListener;

public class ListViewResourceEx extends Activity {
	ArrayAdapter<CharSequence> adapter;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.ch12_listviewarraylist);
		
		adapter = ArrayAdapter.createFromResource(this, R.array.country, android.R.layout.simple_list_item_1);
		
		ListView list = (ListView) findViewById(R.id.ch12_listView);
		list.setAdapter(adapter);
		list.setOnItemClickListener(new OnItemClickListener() {

			@Override
			public void onItemClick(AdapterView<?> parent, View view,
					int position, long id) {
				Log.d("ListViewResourceEx", "position : " + position + ", id : " + id);
				String text = "Select Item = " + adapter.getItem(position);
				Toast.makeText(getApplicationContext(), text, Toast.LENGTH_SHORT).show();				
			}
		});
	}
}
